<?php echo $header; ?>
<?php echo $column_left; ?>
<div id="content">
	<div class="page-header">
    	<div class="container-fluid">
        	<div class="pull-right">
            	<a href="<?php echo $insert; ?>" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="Add New"><i class="fa fa-plus"></i></a>
                <button type="submit" form="form-product" formaction="<?php echo $copy; ?>" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="Copy"><i class="fa fa-copy"></i></button>
                <button type="button" data-toggle="tooltip" title="" class="btn btn-danger" onclick="confirm('Delete/Uninstall cannot be undone! Are you sure you want to do this?') ? $('#form-product').submit() : false;" data-original-title="Delete"><i class="fa fa-trash-o"></i></button>
            </div>
            <h1> <?php echo $heading_title; ?>  </h1>
            <ul class="breadcrumb">
            	<?php foreach ($breadcrumbs as $breadcrumb) { ?>
                	<li> <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
                <?php } ?>
            </ul>
        </div>
    </div>
    <?php if ($error_warning) { ?>
        <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
          <button type="button" class="close" data-dismiss="alert">&times;</button>
        </div>
    <?php } ?>
    <?php if ($success) { ?>
        <div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?>
          <button type="button" class="close" data-dismiss="alert">&times;</button>
        </div>
    <?php } ?>
    <div class="container-fluid">
    	<div class="panel panel-default">
        	<div class="panel-heading">
            	<h3 class="panel-title"><i class="fa fa-list"></i> <?php echo $heading_title; ?> </h3>
            </div>
            <div class="panel-body">  
            	<div class="table-responsive">  
                      <form action="<?php echo $delete; ?>" method="post" enctype="multipart/form-data" id="form">
                        <table class="table table-bordered table-hover">
                          <thead>
                            <tr>
                              <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
                              <td class="center"><?php echo $column_image; ?></td>
                              <td class="left"><?php if ($sort == 'nd.name') { ?>
                                <a href="<?php echo $sort_name; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_name; ?></a>
                                <?php } else { ?>
                                <a href="<?php echo $sort_name; ?>"><?php echo $column_name; ?></a>
                                <?php } ?></td>
                              <td class="left"><?php echo $column_short_description; ?></td>
                              <td class="center"><?php echo $column_viewed; ?></td>              
                              <td class="center"><?php if ($sort == 'n.comment') { ?>
                                <a href="<?php echo $sort_comment; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_comment; ?></a>
                                <?php } else { ?>
                                <a href="<?php echo $sort_comment; ?>"><?php echo $column_comment; ?></a>
                                <?php } ?></td>              
                              <td class="center"><?php if ($sort == 'n.approved') { ?>
                                <a href="<?php echo $sort_approved; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_approved; ?></a>
                                <?php } else { ?>
                                <a href="<?php echo $sort_approved; ?>"><?php echo $column_approved; ?></a>
                                <?php } ?></td>
                              
                              <td class="center"><?php if ($sort == 'n.status') { ?>
                                <a href="<?php echo $sort_status; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_status; ?></a>
                                <?php } else { ?>
                                <a href="<?php echo $sort_status; ?>"><?php echo $column_status; ?></a>
                                <?php } ?></td>
                              <td class="center"><?php echo $column_date_added; ?></td>
                              <td class="right"><?php echo $column_action; ?></td>
                            </tr>
                          </thead>
                          <tbody>
                            <tr class="filter">
                              <td></td>
                              <td></td>
                              <td><input type="text" name="filter_name" value="<?php echo $filter_name; ?>" /></td>
                              <td><input type="text" name="filter_short_description" value="<?php echo $filter_short_description; ?>" style="width: 300px;" /></td>
                              <td align="left"></td>
                              <td align="right"><select name="filter_comment">
                                  <option value="*"></option>
                                  <?php if ($filter_comment) { ?>
                                  <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                                  <?php } else { ?>
                                  <option value="1"><?php echo $text_enabled; ?></option>
                                  <?php } ?>
                                  <?php if (!is_null($filter_comment) && !$filter_comment) { ?>
                                  <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                                  <?php } else { ?>
                                  <option value="0"><?php echo $text_disabled; ?></option>
                                  <?php } ?>
                                </select></td>
                              <td align="center"><select name="filter_approved">
                                  <option value="*"></option>
                                  <?php if ($filter_approved) { ?>
                                  <option value="1" selected="selected"><?php echo $text_yes; ?></option>
                                  <?php } else { ?>
                                  <option value="1"><?php echo $text_yes; ?></option>
                                  <?php } ?>
                                  <?php if (!is_null($filter_approved) && !$filter_approved) { ?>
                                  <option value="0" selected="selected"><?php echo $text_no; ?></option>
                                  <?php } else { ?>
                                  <option value="0"><?php echo $text_no; ?></option>
                                  <?php } ?>
                                </select></td>
                              <td align="right"><select name="filter_status">
                                  <option value="*"></option>
                                  <?php if ($filter_status) { ?>
                                  <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                                  <?php } else { ?>
                                  <option value="1"><?php echo $text_enabled; ?></option>
                                  <?php } ?>
                                  <?php if (!is_null($filter_status) && !$filter_status) { ?>
                                  <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                                  <?php } else { ?>
                                  <option value="0"><?php echo $text_disabled; ?></option>
                                  <?php } ?>
                                </select></td>
                              <td></td>
                              <td align="right"><a onclick="filter();" class="btn btn-primary pull-right"><span><?php echo $button_filter; ?></span></a></td>
                            </tr>
                            <?php if ($blogs) { ?>
                            <?php foreach ($blogs as $blogs_item) { ?>
                            <tr>
                              <td style="text-align: center;"><?php if ($blogs_item['selected']) { ?>
                                <input type="checkbox" name="selected[]" value="<?php echo $blogs_item['blogs_id']; ?>" checked="checked" />
                                <?php } else { ?>
                                <input type="checkbox" name="selected[]" value="<?php echo $blogs_item['blogs_id']; ?>" />
                                <?php } ?></td>
                              <td class="center"><img src="<?php echo $blogs_item['image']; ?>" alt="<?php echo $blogs_item['name']; ?>" style="padding: 1px; border: 1px solid #DDDDDD;" <?php echo $blogs_item['width']; ?> <?php echo $blogs_item['height']; ?> /></td>
                              <td class="left"><a href="<?php echo $blogs_item['name_url']; ?>"><?php echo $blogs_item['name']; ?></a></td>
                              <td class="left"><?php echo $blogs_item['short_description']; ?></td>
                              <td class="center"><?php if ($blogs_item['viewed'] <= 0) { ?>
                              <span style="color: #FF0000;"><?php echo $blogs_item['viewed']; ?></span>
                              <?php } elseif ($blogs_item['viewed'] <= 5) { ?>
                              <span style="color: #FFA500;"><?php echo $blogs_item['viewed']; ?></span>
                              <?php } else { ?>
                              <span style="color: #008000;"><?php echo $blogs_item['viewed']; ?></span>
                              <?php } ?></td>
                              <td class="right"><?php echo $blogs_item['comment']; ?></td>
                              <td class="right"><?php echo $blogs_item['approved']; ?></td>
                              <td class="right"><?php echo $blogs_item['status']; ?></td>
                              <td class="left"><?php echo $blogs_item['date_added']; ?></td>
                              <td class="right"><?php foreach ($blogs_item['action'] as $action) { ?>
                                <a class="btn btn-primary pull-right" href="<?php echo $action['href']; ?>"><i class="fa fa-pencil"></i></a>
                                <?php } ?></td>
                            </tr>
                            <?php } ?>
                            <?php } else { ?>
                            <tr>
                              <td class="center" colspan="8"><?php echo $text_no_results; ?></td>
                            </tr>
                            <?php } ?>
                          </tbody>
                        </table>
                      </form>
                      <div class="pagination"><?php echo $pagination; ?></div>	
                </div>
            </div>
        </div>
    </div>
  
  <?php echo $footer; ?>
 
<script type="text/javascript">
function filter() {
	url = 'index.php?route=catalog/blogs&token=<?php echo $token; ?>';
	
	var filter_name = $('input[name=\'filter_name\']').val();
	if (filter_name) {
		
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}
	
	var filter_short_description = $('input[name=\'filter_short_description\']').val();
	
	if (filter_short_description) {
		url += '&filter_short_description=' + encodeURIComponent(filter_short_description);
	}
	
	var filter_comment = $('select[name=\'filter_comment\']').val();
	
	if (filter_comment != '*') {
		url += '&filter_comment=' + encodeURIComponent(filter_comment);
	}	
	
	var filter_approved = $('select[name=\'filter_approved\']').val();
	
	if (filter_approved != '*') {
		url += '&filter_approved=' + encodeURIComponent(filter_approved);
	}	
	var filter_status = $('select[name=\'filter_status\']').val();
	if (filter_status != '*') {
		url += '&filter_status=' + encodeURIComponent(filter_status);
	}	
	location = url;
}
</script> 
<script type="text/javascript">
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
</script> 
